Till death do us part
Axels New Music releases
Evil gear
Christmas is almost here
Sharp Stuff
Switchblades Icepicks and german knives
Goth and Gore Gifts
Shop right now or else!

here are some of the best and useful php scripts and snippets to help in your projects. Php displayed below. Use the search for specific script lookups. Click the category links to view scripts in Javascript and cgi. To add your own script click the link and add your useful script example.

encode decode validate get post array values with salt
anti injection validate user input get encode get decode

<?php
//many ways to do this just another example
//include this in the top of your page
//encode with salt validate

$redirect='http://spamhaus.org';//send hacker to
$ipfile="ipBan.data";//ip file
$ip $_SERVER['REMOTE_ADDR'];

//check ip ban file before anything

$f fopen($ipfile '.lock''w');
flock($fLOCK_SH);
$lines file($ipfile);
flock($fLOCK_UN);
fclose($f);
unlink($file '.lock');
foreach (
$lines as $line) {

$parts explode('.'$ip);
//adjust to check each part of ip
//set nowfor checking first 3 parts    
//    $check2 = $parts[0] . '.' . $parts[1];
    
$check3 $parts[0] . '.' $parts[1] . '.' $parts[2];
//    $check4 = $parts[0] . '.' . $parts[1] . '.' . $parts[2] . '.' . $parts[3];
if (strstr($line,$check3)) {
echo 
"I told you have been banned.";
//echo("<meta http-equiv=\"Refresh\" content=\"2;URL=$redirect\">");
exit();
}
}

if(!isset(
$_SESSION['Cksum'])){
makeCksum();
}

function 
makeCksum(){
       
$str "";
       for (
$i=0;$i<32;++$i)
               
$str .= chr(rand(32,126));
       
$_SESSION['Cksum'] = $str;
}
//encode your get with saved to session salt

//example get link
echo "<a href=\"?action=".encode($x)."\">link</a>";

function 
encode($x) {
    return 
strtr(base64_encode(substr($_SESSION['Cksum'],rand(0,28),4) . $x), '+/=''-_~');
}

//decode get and validate
function decode($x) {
    
$y base64_decode(strtr($x'-_~''+/='));
    if (
strpos($_SESSION['Cksum'],substr($y,0,4)) === false) return false;
    return 
substr($y,4-strlen($y));
}

   if(!
decode($x)) {//if salt not decoded ban ip
    
$fp fopen($ipfile"a");    
    
$canWrite false
    while (!
$canWrite) { 
    
$canWrite flock($fpLOCK_EX); 
     } 
    
fwrite($fp"$ip\n");
    
fclose($fp);
   echo 
"Success you have been banned.";
echo(
"<meta http-equiv=\"Refresh\" content=\"0;URL=$redirect\">");
   exit();
   }

?>


Add your comment.













No comments yet

Search ScriptsnTips


Php JavaScripts CGI/Perl